

fn main() {
    'outer: loop {
        println!("Entered the outer loop");

        'inner: loop {
            println!("Entered the inner loop");

            // 这只是中断内部的循环
            //break;

            // 这会中断外层循环
            break 'outer;
        }

        println!("This point will never be reached");
    }

    println!("Exited the outer loop");

    let mut counter = 0;

    let result = loop {
        counter += 1;

        if counter == 10 {
            // 这里会作为loop的值返回
            break counter * 2;
        }
    };

    assert_eq!(result, 20);

    // 诡异且混乱的break机制
    // let result = 's: loop {
    //     counter += 1;

    //     if counter == 10 {
    //         // 这里会作为loop的值返回
    //         break 's;
    //     }
    // };

    // println!("{}", result);

    #[allow(non_camel_case_types)]
    #[derive(Debug)]
    struct  point {
        x: i32, 
        y: i32,
    }

    let mut foo = point { x: 1, y: 2 };
    // let mut ref_foo_2 = &mut foo;
    let ref_foo_2 = &mut foo;
    ref_foo_2.y = 100;
    println!("{:?}", ref_foo_2);
}
